package gui.secondary;

import java.awt.Color;
import java.net.URL;

import javax.swing.JLabel;
import javax.swing.JScrollPane;

import tool.CustomizedButton;

import controller.gui.CancelButtonController;
import controller.gui.mainmenu.MapObjectWizardController;
import controller.gui.mapobjectmenu.MapObjectConceptBrowseController;
import controller.gui.mapobjectmenu.MapObjectConceptSelectionBoxController;
import controller.gui.mapobjectmenu.MapObjectOKButtonController;
import controller.gui.mapobjectmenu.MapObjectRendererBrowseController;
import controller.gui.mapobjectmenu.MapObjectRendererSelectionBoxController;

import gui.DescribedCustomizedButton;
import gui.SelectionBox;
import gui.SecondaryMenu;
import gui.TextPanel;

/** Il SecondaryMenu relativo all'opzione MapObject del menu primario.
 * @author Daniele
 * @version 1.3 */
public class MapObjectSecondaryMenu extends SecondaryMenu {

	private static final long serialVersionUID = 2942874406951531490L;
	
	// Scritte e info dei pulsanti di questo SecondaryMenu.
	private static final String TXT_BROWSE_CONCEPT = "Browse Concepts";
	private static final String TXT_BROWSE_RENDERER = "Browse Renderers";
	private static final URL DESC_BROWSE_CONCEPT = MapLayerSecondaryMenu.class.getResource("BrowseBkConceptsDESC.html");
	private static final URL DESC_BROWSE_RENDERER = MapLayerSecondaryMenu.class.getResource("BrowseBkRenderersDESC.html");
	
	/** La scritta contenuta nell'etichetta associata al riquadro dei concepts. */
	private static final String CONCEPTS_LABEL = "Available MapObject Concepts:";
	/** La scritta contenuta nell'etichetta associata al riquadro dei renderers. */
	private static final String RENDERER_LABEL = "Available MapObject Renderers:";

	/** L'etichetta che introduce il riquadro dei MapLayerConcepts. */
	private JLabel conceptLabel;
	/** Il riquadro entro il quale mostrare i vari tipi di MapLayerConcepts. */
	private SelectionBox chooseConceptWindow;
	/** L'etichetta che introduce il riquadro dei MapLayerRenderers. */
	private JLabel rendererLabel;
	/** Il riquadro entro il quale mostrare i vari tipi di Renderers possibili. */
	private SelectionBox chooseRendererWindow;
	/** Il pulsante che permette di sfogliare i files dei concepts. */
	private CustomizedButton browseConceptButton;
	/** Il pulsante che permette di sfogliare i files dei renderers. */
	private CustomizedButton browseRendererButton;
	
//	public void addListeners(MapObjectOKButtonController mook,CancelButtonController mocancel,MapObjectConceptBrowseController moconceptbrowse,MapObjectRendererBrowseController morendererbrowse,MapObjectConceptSelectionBoxController moconceptbox,MapObjectRendererSelectionBoxController morendererbox){
//		mook.wire(okButton,this);
//		mocancel.wire(cancelButton, this);
//		
//		moconceptbrowse.wire(browseConceptButton);
//		morendererbrowse.wire(browseRendererButton);
//		
//		moconceptbox.wire(chooseConceptWindow);
//		morendererbox.wire(chooseRendererWindow);
//		
//		//FIXME un giorno secondo me moconceptbrowse e moconcept box dovrebbero stare in uno stesso grande controller ;)
//		moconceptbrowse.wire(moconceptbox);
//		morendererbrowse.wire(morendererbox);
//	}
	
	
	public MapObjectSecondaryMenu(){
		
		super();
		
		descriptionLabel = new TextPanel();
		descriptionLabel.loadContent(MapObjectSecondaryMenu.class.getResource("MapObjectsDESC.html"));
		this.initializeJScrollPane();
		this.addComponentToLayout(descriptionLabelScrollPane, 0, 0, 2.5, 10, 0, 2);
		
		conceptLabel = new JLabel(CONCEPTS_LABEL);
		this.addComponentToLayout(conceptLabel, 0, 1, 0.5, 0, 0, 2);
		
		chooseConceptWindow = new SelectionBox();
		JScrollPane scrollConceptPane = new JScrollPane(this.chooseConceptWindow, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		this.addComponentToLayout(scrollConceptPane, 0, 2, 2, 0, 0, 2);
		
		this.browseConceptButton = new DescribedCustomizedButton(MapObjectSecondaryMenu.TXT_BROWSE_CONCEPT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,MapObjectSecondaryMenu.DESC_BROWSE_CONCEPT);
		this.addComponentToLayout(browseConceptButton, 0, 3, 0.5, 10, 0, 2);
		this.browseConceptButton.addMouseListener(descriptionLabel);
		
		rendererLabel = new JLabel(RENDERER_LABEL);
		this.addComponentToLayout(rendererLabel, 0, 4, 0.5, 0, 0, 2);
		
		chooseRendererWindow = new SelectionBox();
		JScrollPane scrollRendererPane = new JScrollPane(this.chooseRendererWindow, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		this.addComponentToLayout(scrollRendererPane, 0, 5, 2, 0, 0, 2);
		
		this.browseRendererButton = new DescribedCustomizedButton(MapObjectSecondaryMenu.TXT_BROWSE_RENDERER,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,MapObjectSecondaryMenu.DESC_BROWSE_RENDERER);
		this.addComponentToLayout(browseRendererButton, 0, 6, 0.5, 10, 0, 2);
		this.browseRendererButton.addMouseListener(descriptionLabel);
		
		this.addToMapButton = new DescribedCustomizedButton(SecondaryMenu.TXT_ADD,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,SecondaryMenu.DESC_ADD);
		this.addComponentToLayout(addToMapButton, 0, 7, 0.5, 10, 0, 2);
		this.addToMapButton.addMouseListener(descriptionLabel);
		
		this.okButton = new DescribedCustomizedButton(SecondaryMenu.TXT_OK,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,SecondaryMenu.DESC_OK);
		this.addComponentToLayout(okButton, 0, 8, 0.5, 10, 10, 1);
		this.okButton.addMouseListener(descriptionLabel);
		
		this.cancelButton = new DescribedCustomizedButton(SecondaryMenu.TXT_CANCEL,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,SecondaryMenu.DESC_CANCEL);
		this.addComponentToLayout(cancelButton, 1, 8, 0.5, 10, 10, 1);
		this.cancelButton.addMouseListener(descriptionLabel);
	}
	
	/** Getter per l'etichetta che precede il riquadro dei Concepts.
	 * @return the conceptLabel */
	public JLabel getConceptLabel() {
		return conceptLabel;
	}

	/** Getter per il riquadro di selezione dei Concepts.
	 * @return the chooseConceptWindow. For further information visit {@link #chooseConceptWindow} */
	public SelectionBox getChooseConceptWindow() {
		return chooseConceptWindow;
	}

	/** Getter per l'etichetta che precede il riquadro dei Renderers.
	 * @return the rendererLabel */
	public JLabel getRendererLabel() {
		return rendererLabel;
	}

	/** Getter per il riquadro di selezione dei Renderers.
	 * @return the chooseRendererWindow. For further information visit {@link #chooseRendererWindow} */
	public SelectionBox getChooseRendererWindow() {
		return chooseRendererWindow;
	}

	/** Getter per il pulsante che sfoglia tra i Concepts.
	 * @return the browseConceptButton. For further information visit {@link #browseConceptButton} */
	public CustomizedButton getBrowseConceptButton() {
		return browseConceptButton;
	}

	/** Getter per il pulsante che sfoglia tra i Renderers.
	 * @return the browseRendererButton. For further information visit {@link #browseRendererButton}*/
	public CustomizedButton getBrowseRendererButton() {
		return browseRendererButton;
	}
}
